//
//  UIImage+ImageDown.m
//  iNews
//
//  Created by lanou3g on 14-12-4.
//  Copyright (c) 2014年 张在青. All rights reserved.
//

#import "UIImage+ImageDown.h"

@implementation UIImage (ImageDown)


//异步加载图片的方法,先返回的是一个占位符
+ (UIImage *)imageWithUrlString:(NSString *)urlString myBlock:(imgBlock)mb
{
    NSURL *url = [NSURL URLWithString:urlString];
    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
    
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
       
        UIImage *image = [UIImage imageWithData:data];
        mb(image);
        
    }];
    
    return [UIImage imageNamed:@"placehodel.png"];
}

@end
